<extend name="Public/base"/>

<block name="style">
    <style type="text/css">
.btn{

    background: #09c;
}
.btn:hover{
    background: #09c;
}
        .zaixian_shou{
            width: 33px;
            height: 33px;
            border-radius: 50% 50%;

        }
        .path2_status{
            width: 33px;
            height: 33px;
            border-radius: 50% 50%;

        }
        .frozen{
            width: 33px;
            height: 33px;
            border-radius: 50% 50%;

        }
        ._tixian{
            width: 33px;
            height: 33px;
            border-radius: 50% 50%;

        }
      .side-sub-menu > li > .item {
                color: #000;
                font-family: '宋体';
                font-size:15px;padding:0px;
                line-height: 25px;
            }
    .sidebar {
        background: #3697A0;
        position: absolute;
    }   
  

     /* 头部Logo,主导航*/
            body{
                color:#000;
                font-family: '宋体';
                font-weight: 900;
            }
            .header {
                background-color:   #3697A0;
                height: 45px;
            }
            /* 主导航 */
            .main-nav a {
                height: 45px;
                color: #150303;
            }
            .main-nav a:hover {
                height: 45px;
                background-color:#70bcf3;
                color: #150303;
            }
            .main-nav .current{
                height: 45px;
                background-color: #70bcf3;
            }
            .main-nav .current a {
                height: 45px;
                background-color: #70bcf3;
                color: #150303;
            }
            .logo{
                height: 45px;
                background: #ccc;
            }
            .sidebar{
                margin-top:-5px;
                background:     #3697A0;
                color: #000;
                position: fixed;
                height: 110%;
                margin-top:-40px;
            }
            .subnav h3{
                color: #000;
            }

            .main-nav {
                /*width:100%;*/
                float: none;
                height: auto;
            }

            .mainnav {
                /*height: auto;*/
                height: 100%;
            }

            .main-nav li{
                float: none;
                width:180px;
            }

                        /* Table Head */
.data-table thead th {
background-color: rgb(81, 130, 187);
color: #fff;
border-bottom-width: 0;
}

/* Column Style */
.data-table td {
color: #000;
}
/* Heading and Column Style */
.data-table tr, .data-table th {
border-width: 1px;
border-style: solid;
border-color: rgb(81, 130, 187);
}

/* Padding and font style */
.data-table td, .data-table th {
padding: 5px 10px;
font-size: 12px;
font-family: Verdana;
font-weight: bold;
}
    </style>
</block>

<block name="body">

	<!-- <div class="main-title" style="margin-top:5px;">
		<h2>商户列表</h2>
	</div> -->
    <div class="cf" style="margin-top: 5px;margin-left:-50px;margin-bottom:10px;">
            <div style="float: left;padding-left: 50px;" class="">账户总余额：<span style="color: #ff6600">{$sum.total}</span>元</div>
            <div style="float: left;padding-left: 50px;" class="">总分润:<span style="color: #c43c35">{$sum.divide}</span>元</div>
            <div style="float: left;padding-left: 50px;" class="">总交易量:<span style="color: #c43c35">{$sum.t_money}</span>元</div>
            <div style="float: left;padding-left: 50px;" class="">今日进账：<span style="color: #0000ff">{$sum.td_in}</span>元</div>
            <div style="float: left;padding-left: 50px;" class="">今日提现:<span style="color: #c43c35">{$sum.td_out}</span>元</div>

        </div>
   
    <div class="cf">
        <div class="fl">
            <button class="btn all_pass" >一键审核</button>

        </div>
        <!-- 高级搜索 -->
        <div class="search-form fr cf">
            <div class="sleft">            
                <input name="title" class="search-input" style="width:200px;" value="" placeholder="请输入名字、店名、商户编号" type="text">
                <a class="sch-btn" href="javascript:;" id="search" url="{:U('find_one')}"><i class="btn-search"></i></a>
            </div>

        </div>
    </div>

	<div class="data-table table-striped" >
		<table style="font-size:14px;">
			<thead>
				<tr>
                    <th class="row-selected row-selected"><input class="check-all" type="checkbox"/></th>
                    <th>用户UID</th>
					<th>用户编号</th>
                    <th>姓名</th>
                    <th>手机号码</th>
                    <th>店铺名称</th>
                    <th>支付宝账号</th>
                    <th>账户余额</th>
                    
                    <th>上级</th>
                    <th>提现</th>
					<th>操作</th>
				</tr>
			</thead>  
			<tbody>
				<notempty name="_list">
				<volist name="_list" id="rows">
                   
                        <tr>
                            <td><input class="ids" type="checkbox" name="id[]" value="{$rows['uid']}" /></td>
                            <td class="uid">{$rows['uid']}</td>
                            <td>{$rows['yh_uid']}</td>
                            
                            <td>{$rows['name']}</td>
                            <td>{$rows['phone']}</td>
                            <td>{$rows['shop_name']}</td>
                            <td>{$rows['alipay']}</td>
                            <php>
                                $one=D('Gather')->where('uid='.$rows['uid'])->find();
                            </php>
                            <td>{$one['money']}</td>
   

                            
                            <td>

                                <php>
                                    if($rows['pid']>1){
                                        $pa=D('Ptyh')->where('uid='.$rows['pid'])->find();
                                        $id=$pa['id'];

                                        $name=$pa['name'];
                                        if(empty($name)){
                                            $id=0;
                                            $name="该上级未认证";
                                        }
                                    }else if($rows['pid']==0||$rows['pid']==1){
                                        $id=0;
                                        $name="直属平台"; 
                                    }
                                </php>
                                <if condition="$id eq 0">
                                            {$name}
                                    <else/>
                                    <a href="{:U('yh_view?id='.$id)}">
                                        {$name}
                                    </a>
                                </if>
                                
                            </td>

                            <td class="">
                                    <button class="_tixian">提现</button>

                            </td>

                                                      
                            <td>

                                &nbsp;&nbsp;
                                <a title="详细" href="{:U('yh_view2?id='.$rows['id'])}">详细</a>
                            </td>
                        </tr>

                
					
				</volist>
				<else/>
				<td colspan="14" class="text-center"> aOh! 暂时还没有内容! </td>
				</notempty>
			</tbody>
		</table>

        



	</div>
    <div class="" style="margin-top: 10px;">

    <div class="page"  style="float:left;margin-right:300px;margin-top:20px;">{$_page}</div>
</block>

<block name="script">
    <link href="/Public/static/datetimepicker/css/datetimepicker.css" rel="stylesheet" type="text/css">
    <link href="/Public/static/datetimepicker/css/dropdown.css" rel="stylesheet" type="text/css">
    <script type="text/javascript" src="/Public/static/datetimepicker/js/bootstrap-datetimepicker.min.js"></script>
    <script type="text/javascript" src="/Public/static/datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js" charset="UTF-8"></script>
<script type="text/javascript">
    $(function(){
        //搜索功能
        $("#search").click(function(){
            var url = $(this).attr('url');
            var status = $("#sch-sort-txt").attr("data");
            var type   = $("#sch-sort-txt_type").attr("data");
            var query  = $('.search-form').find('input').serialize();
            query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g,'');
            query = query.replace(/^&/g,'');
            if(status != ''){
                query += '&status=' + status + "&" + query;
            }
            if(type != ''){
                query += '&type=' + type + "&" + query;
            }
            if( url.indexOf('?')>0 ){
                url += '&' + query;
            }else{
                url += '?' + query;
            }
            window.location.href = url;
        });

            //回车搜索
        $(".search-input").keyup(function(e){
            if(e.keyCode === 13){
                $("#search").click();
                return false;
            }
        });


        Think.setValue("extend", {$info.extend|default=0});
        //导航高亮
        highlight_subnav('{:U('ptyh2')}');




        /* 状态搜索子菜单 */
        $(".search-form").find(".drop-down1").hover(function(){
            $("#sub-sch-menu").removeClass("hidden");
        },function(){
            $("#sub-sch-menu").addClass("hidden");
        });
        $("#sub-sch-menu li").find("a").each(function(){
            $(this).click(function(){
                var text = $(this).text();
                $("#sch-sort-txt").text(text).attr("data",$(this).attr("value"));
                $("#sub-sch-menu").addClass("hidden");
            })
        });

        $(".search-form").find(".drop-down_type").hover(function(){
            $("#sub-sch-menu_type").removeClass("hidden");
        },function(){
            $("#sub-sch-menu_type").addClass("hidden");
        });

        $("#sub-sch-menu_type li").find("a").each(function(){
            $(this).click(function(){
                var text = $(this).text();
                $("#sch-sort-txt_type").text(text).attr("data",$(this).attr("value"));
                $("#sub-sch-menu_type").addClass("hidden");
            })
        });
        $('#time-start').datetimepicker({
            format: 'yyyy-mm-dd',
            language:"zh-CN",
            minView:2,
            autoclose:true
        });

        $('#time-end').datetimepicker({
            format: 'yyyy-mm-dd',
            language:"zh-CN",
            minView:2,
            autoclose:true
        });





        $('.zaixian_shou').click(function(){
            var current=$(this)
            var text=current.html();
            var _this=current.parent().parent().find('.uid');
            var uid =_this.text();
            if(text=='开启'){
              var  status=0;
            }else{
              var  status=1;
            }
            $.ajax({
                type:'post',
                data:{'status':status,'uid':uid,'type':'status'},
                url:"{:U('ptyh')}",
                success:function(m){
                    if(m==1){
                        // current.html('')
                        if(status==1){

                            current.html('开启')
                        }else{
                            current.html('关闭')
                        }
                        
                    }
                }

            })
        })



        $('.path2_status').click(function(){
            var current=$(this)
            var text=current.text();
            var _this=current.parent().parent().find('.uid');
            var uid =_this.text();
            if(text=='开启'){
              var  status=0;
            }else{
              var  status=1;
            }
            $.ajax({
                type:'post',
                data:{'path2_status':status,'uid':uid,'type':'path2_status'},
                url:"{:U('ptyh')}",
                success:function(m){
                    if(m==1){
                        current.text('')
                        if(status==1){
                            current.text('开启')
                        }else{
                            current.text('关闭')
                        }
                        
                    }
                }

            })
        })



        $('._tixian').click(function(){
            var current=$(this)
            var _this=current.parent().parent().find('.uid');
            var uid =_this.text();
            $.ajax({
                type:'post',
                data:{'uid':uid},
                url:"{:U('tixian_by')}",
                success:function(m){
                    alert(m)
                }

            })
        })




    })


</script>
<script type="text/javascript">
        $('._frozen').on('click','.frozen',function(){
        // $('.frozen').click(function(){
            var current=$(this)
            var text=current.html();

            var _this=current.parent().parent().find('.uid');
            var uid =_this.text();
            
            if(text=='正常'){
                var  status=0;
                var str=''
                str+='<input class="input" type="text" style="width:100%;height:30px;line-height:30px;" name="content" value="" placeholder="填写冻结原因">';
                current.parent().html(str);


               $('._frozen').on('blur','input',function(){
                    var frozen_val=$('._frozen input').val();
                    
                    $.ajax({
                        type:'post',
                        data:{'frozen':status,'uid':uid,'type':'frozen','frozen_val':frozen_val},
                        url:"{:U('ptyh')}",
                        success:function(m){
                          
                            if(m==1){
                                if(status==1){
                                    var btn='<button class="frozen">正常</button>';

                                    $('._frozen input').parent().html(btn);
                                }else{
                                    alert('冻结成功！')
                                    var btn='<button class="frozen">冻结</button>';
                                    // alert(btn)

                                    $('._frozen input').parent().html(btn);

                                }
                                
                            }
                        }

                    })

              });
              





            }else{
              var  status=1;
              $.ajax({
                type:'post',
                data:{'frozen':status,'uid':uid,'type':'frozen'},
                url:"{:U('ptyh')}",
                success:function(m){
                    if(m==1){
                        // current.html('')
                        if(status==1){

                            current.html('正常')
                        }else{
                            current.html('冻结')
                        }
                        
                    }
                }

            })
            }
            
        })


$('.all_pass').click(function(){
    obj = document.getElementsByClassName("ids");
    // console.log(obj)
    check_val = [];
    for(k in obj){
        if(obj[k].checked)
            check_val.push(obj[k].value);
    }
    $.ajax({
        type:'post',
        data:{'ids':check_val},
        // dataType:'json',
        url:"{:U('ptyh2')}",
        success:function(m){
            alert(m)
            location.reload()
                // alert("提交扣款人数："+ids+"，成功："+success+"，失败："+default+"。失败合同号："+ht+"对应失败原因："+error)
        }
    })
})






</script>
</block>